package top.dingwen.io.treasure.encrypt.api.web;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.dingwen.io.treasure.encrypt.api.annotation.ApiEncrypt;
import top.dingwen.io.treasure.encrypt.api.constant.EncryptApiConstant;
import top.dingwen.io.treasure.webplus.result.Result;
import top.dingwen.io.treasure.webplus.web.controller.BaseViewController;

import java.util.Map;


/**
 * 加解密场景
 *
 * @author dingwen
 * @since 2023/5/23 11:07
 */
@RestController
@Slf4j
@RequestMapping("common/encrypts")
public class EncryptApiIndexController implements BaseViewController {

    /**
     * 测试加解密
     *
     * @param body 请求体
     * @return {@link Result }<{@link Map }<{@link Object }, {@link Object }>>
     */
    @ApiEncrypt(response = true)
    @PostMapping("/test")
    public Result<Map<Object, Object>> testEncrypt(@RequestBody Map<Object, Object> body) {
        log.info("{},{},解密之后的数据,{}", EncryptApiConstant.EN_L_P_S, EncryptApiConstant.EN_L_P_API ,JSONUtil.toJsonStr(body));
        return success(body);
    }

}
